package com.桥接模式.factory;

import com.桥接模式.fileService.ParentServiceInterface;
import com.桥接模式.fileType.LunWenQuanWenUtil;
import com.桥接模式.fileType.LunWenZhaiYaoUtil;
import com.桥接模式.fileType.ParentInterface;
import com.桥接模式.fileType.PuTongWenDangUtil;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 定义服务类型工厂类类：二级工厂类
 */
@Service
public class FileTypeFactory {

    private static final ConcurrentHashMap<String, ParentInterface> map=new ConcurrentHashMap<>();

    @PostConstruct
    public void init (){
        map.put(FileTypeEnum.LUN_WEN_QUAN_WEN.name(),new LunWenQuanWenUtil());
        map.put(FileTypeEnum.LUN_WEN_ZHAI_YAO.name(),new LunWenZhaiYaoUtil());
        map.put(FileTypeEnum.PU_TONG_WEN_DANG.name(),new PuTongWenDangUtil());
    }

    public ParentInterface get(FileTypeEnum fileTypeEnum){
        return map.get(fileTypeEnum.name());
    }
}
